﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniMana.Utils.Controls;

namespace UniMana.Data
{
    public class System_Group_RuleInfo
    {
           #region /*Không thay đổi*/
        public bds m_bds = new bds();

        public void Save()
        {
            m_bds.EndEdit();
            m_data.m_DCSave.SubmitChanges();
        }
        #endregion /*Không thay đổi*/

        private DBMain m_data = new DBMain();
        #region [Properties - Thuộc tính]
        public System_Group_Rule Properties
        {
            get { return m_bds.Current as System_Group_Rule; }
        }
        #endregion

        public System_Group_RuleInfo(int _guiGroupKey, Guid _guiRuleKey)
        {
            var Iquery = m_data.m_DCSave.System_Group_Rules.Where(p => p.System_RuleKey == _guiRuleKey && p.System_GroupKey == _guiGroupKey);
             m_bds.DataSource = Iquery;
             var Row = Iquery.FirstOrDefault();
             if (Row == null)
             {
                 System_Group_Rule sur = new System_Group_Rule();
                 sur.System_RuleKey = _guiRuleKey;
                 sur.System_GroupKey = _guiGroupKey;
                 Row = sur;
                 m_bds.Add(Row);
                 m_bds.MoveLast();
             }
        }

     

        public void Delete()
        {
            m_bds.DeleteCurrent();
        }
    }
}
